package com.example.study_mybatis.model;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

public class PageInfo<T> {
    @Getter
    @Setter
    private Integer pageNum;
    @Getter
    @Setter
    private Integer pageSize;
    @Getter
    @Setter
    private Integer total;
    @Getter
    @Setter
    private List<T> list;

    private Integer start;

    public Integer getStart() {
        if (pageNum == null || pageSize == null) {
            return null;
        }
        return (this.pageNum - 1) * this.pageSize;
    }

    public PageInfo() {
        this.pageNum = 1;
        this.pageSize = 10;
    }

    public PageInfo(Integer pageNum, Integer pageSize) {
        this.pageSize = pageSize;
        this.pageNum = pageNum;
    }

}
